#include <bits/stdc++.h>

using namespace std;
#define int long long

void solve()
{
    int x, y;
    cin >> x >> y;
    if (x > y) swap(x, y);
    int g = gcd(x, y);
    x /= g;
    y /= g;
    int a = __lg(x + y);
    if ((1 << a) == x + y) cout << a << endl;
    else cout << -1 << endl;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int _ = 1;
    cin >> _;
    while (_--)
    {
        solve();
    }
    return 0;
}